Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.3.28
|
Leadtools.Dicom.Common.Anonymization Namespace : MacroSubsitutionDelegate<T> Delegate |
public delegate string MacroSubsitutionDelegate<T>( T item, string name, params object[] parameters )
'Declaration
Public Delegate Function MacroSubsitutionDelegate(Of T)( _ ByVal item As T, _ ByVal name As String, _ ByVal ParamArray parameters() As Object _ ) As String
'Usage
Dim instance As New MacroSubsitutionDelegate(Of T)(AddressOf HandlerMethod)
generic<typename T> public delegate String^ MacroSubsitutionDelegate( T^ item, String^ name, ... array<Object^>^ parameters )
This example adds two macros to the macro processor and processes a string.
Imports Leadtools.Dicom.Common.Anonymization <TestMethod()> _ Public Sub MacroProcessorSample() Dim processor As New MacroProcessor(Of Object)() ' ' add two macros to the macro processor ' processor.Macros.Add("current_date", New MacroSubsitutionDelegate(Of Object)(AddressOf CurrentDateMacro)) processor.Macros.Add("current_time", New MacroSubsitutionDelegate(Of Object)(AddressOf CurrentTimeMacro)) ' ' Process a macro string ' Console.WriteLine(processor.Process(processor, "${current_date} ==> ${current_time}")) End Sub Private Function CurrentDateMacro(ByVal userData As Object, ByVal name As String, ByVal ParamArray parameters As Object()) As String Return DateTime.Now.ToShortDateString() End Function Private Function CurrentTimeMacro(ByVal userData As Object, ByVal name As String, ByVal ParamArray parameters As Object()) As String Return DateTime.Now.ToShortTimeString() End Function
using Leadtools.Dicom.Common.Anonymization; [TestMethod] public void MacroProcessorSample() { MacroProcessor<object> processor = new MacroProcessor<object>(); // // add two macros to the macro processor // processor.Macros.Add("current_date", new MacroSubsitutionDelegate<object>(CurrentDateMacro)); processor.Macros.Add("current_time", new MacroSubsitutionDelegate<object>(CurrentTimeMacro)); // // Process a macro string // Console.WriteLine(processor.Process(processor, "${current_date} ==> ${current_time}")); } private string CurrentDateMacro(object userData, string name, params object[] parameters) { return DateTime.Now.ToShortDateString(); } private string CurrentTimeMacro(object userData, string name, params object[] parameters) { return DateTime.Now.ToShortTimeString(); }